import { BaseItemNormal } from "./BaseItemNormal";
import { ItemData } from "../../../resource/info/ItemData";
import { DisplayUtil } from "../../../../common/DisplayUtil";
type int = number;
//class ItemsBox
    
    export  class ItemsBox /* flash.display.Sprite */
    {
        

        public setItems(arg1: Array<any>, arg2: int=-1): void
        {
            var loc1=null;
            this.clear();
            var loc2=0;
            while (loc2 < arg1.length) 
            {
                if (!(arg1[loc2] == "" || arg1[loc2] == 0)) 
                {
                    loc1 = new BaseItemNormal();
                    loc1.setSize(this.itemWidth, this.itemHeight);
                    loc1.itemData = arg1[loc2] is ItemData ? arg1[loc2] : new ItemData(parseInt(arg1[loc2]));
                    if (arg2 > 0) 
                    {
                        loc1.x = loc2 % arg2 * (this.itemWidth + this.hGat);
                        loc1.y = Math.floor(loc2 / arg2) * (this.itemHeight + this.vGat);
                    }
                    else 
                    {
                        loc1.x = loc2 * (this.itemWidth + this.hGat);
                        loc1.y = 0;
                    }
                    this._outHeight = loc1.y + this.itemHeight + this.vGat;
                    this.addChild(loc1);
                }
                ++loc2;
            }
            return;
        }

        public getItemNameByIndex(arg1: int): string
        {
            var loc1=null;
            if (this.numChildren > arg1) 
            {
                loc1 = this.getChildAt(arg1) as BaseItemNormal;
                if (loc1.itemData) 
                {
                    return loc1.itemData.name;
                }
            }
            return "";
        }

        public /* override */ get height(): number
        {
            return this._outHeight;
        }

        public clear(): void
        {
            DisplayUtil.removeAllChild(this);
            return;
        }

        public /* var */hGat: int=10;

        public /* var */vGat: int=10;

        public /* var */itemWidth: int=32;

        public /* var */itemHeight: int=32;

        /* internal */ /* var */_outHeight: int;
    }
